package com.ruicar.afs.cloud.manage.creditchange.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruicar.afs.cloud.bizcommon.print.entity.ComPrintFormSealMapping;
import com.ruicar.afs.cloud.bizcommon.print.service.ComPrintFormSealMappingService;
import com.ruicar.afs.cloud.common.aspect.DataAccess;
import com.ruicar.afs.cloud.common.config.ContractFeginConfig;
import com.ruicar.afs.cloud.common.core.exception.AfsBaseException;
import com.ruicar.afs.cloud.common.core.security.util.SecurityUtils;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.common.modules.contract.enums.ProcessStatusEnum;
import com.ruicar.afs.cloud.common.util.EmptyUtils;
import com.ruicar.afs.cloud.components.datadicsync.DicHelper;
import com.ruicar.afs.cloud.components.datadicsync.dto.DicDataDto;
import com.ruicar.afs.cloud.easypass.process.dto.ApplySigningInfoDTO;
import com.ruicar.afs.cloud.easypass.process.dto.SigningCustInfoDTO;
import com.ruicar.afs.cloud.easypass.process.feign.ContractSigningFeign;
import com.ruicar.afs.cloud.image.condition.OcrDiscernCondition;
import com.ruicar.afs.cloud.image.entity.ComAttachmentFile;
import com.ruicar.afs.cloud.image.entity.ComAttachmentManagement;
import com.ruicar.afs.cloud.image.service.ComAttachmentManagementService;
import com.ruicar.afs.cloud.manage.api.dto.SmallprogramDto;
import com.ruicar.afs.cloud.manage.common.entity.ComAttachementFile;
import com.ruicar.afs.cloud.manage.common.entity.ManageBankCardChange;
import com.ruicar.afs.cloud.manage.common.service.ComAttachementFileService;
import com.ruicar.afs.cloud.manage.common.service.ContractOCRInterService;
import com.ruicar.afs.cloud.manage.common.service.ManageBankCardChangeService;
import com.ruicar.afs.cloud.manage.common.vo.BankCardOcrDiscernVo;
import com.ruicar.afs.cloud.manage.common.vo.IdCardBackOcrDiscernVo;
import com.ruicar.afs.cloud.manage.common.vo.IdCardFrontOcrDiscernVo;
import com.ruicar.afs.cloud.manage.creditchange.condition.BankCardChangeCondition;
import com.ruicar.afs.cloud.manage.creditchange.condition.BankCardDetilCondition;
import com.ruicar.afs.cloud.manage.creditchange.condition.SmallprogarmTemplateCondition;
import com.ruicar.afs.cloud.manage.creditchange.condition.TencentCloudNuclearBodyBankCondition;
import com.ruicar.afs.cloud.manage.creditchange.enums.BankTemplateIdEnum;
import com.ruicar.afs.cloud.manage.creditchange.util.TranslateBankCodeUntil;
import com.ruicar.afs.cloud.manage.creditchange.vo.BankApprovalVo;
import com.ruicar.afs.cloud.manage.creditchange.vo.BankCardManageVO;
import com.ruicar.afs.cloud.manage.creditchange.vo.BankCardOCRVO;
import com.ruicar.afs.cloud.manage.workflow.processor.ApproveTaskProcessor;
import com.ruicar.afs.cloud.manage.workflow.service.WorkTaskAssignInfoService;
import com.ruicar.afs.cloud.parameter.commom.entity.TsysAddressParam;
import com.ruicar.afs.cloud.parameter.commom.service.TsysAddressParamService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Author chuke
 * @create 2020/6/29 18:25
 * 客户信息变更模块
 */
@Slf4j
@RestController
@RequestMapping("/bankCardChange")
@AllArgsConstructor
public class BankCardChangeController {
    private final ManageBankCardChangeService bankCardChangeService;
    private final ApproveTaskProcessor approveTaskProcessor;
    private final WorkTaskAssignInfoService workTaskAssignInfoService;
    private final ContractSigningFeign contractSigningFeign;
    private final ContractFeginConfig contractFeginConfig;
    private final ContractOCRInterService contractOCRInterService;
    private final ComAttachementFileService comAttachementFileService;
    private final TsysAddressParamService tsysAddressParamService;
    private final ComAttachmentManagementService comAttachmentManagementService;
    private final ComPrintFormSealMappingService comPrintFormSealMappingService;

    @DataAccess(tables = {"manage_bank_card_change"}, key = "condition.channelId")
    @ApiOperation(value = "银行卡信息申请或暂存过的案件列表")
    @PostMapping("/getManageBankCardChangeList")

    public IResponse<IPage<ManageBankCardChange>> getManageBankCardChangeContractNo(@RequestBody BankCardChangeCondition condition) {
        condition.setProcessPerson(SecurityUtils.getUser().getUserRealName());
        Page page = new Page(condition.getPageNumber(), condition.getPageSize());
        IPage list = bankCardChangeService.getManageBankCardChangeList(page, condition);
        list.setRecords(approveTaskProcessor.handle(list.getRecords()));
        return new IResponse().setData(list);
    }


    @ApiOperation(value = "客户银行卡信息变更")
    @PostMapping("/changeContractBankCardInfo")
    public IResponse contractBankCardInfoChange(@RequestBody BankCardManageVO bankVO) throws ParseException {
        ManageBankCardChange bankChange = bankCardChangeService.saveBankCardRecord(bankVO);
        TencentCloudNuclearBodyBankCondition condition = new TencentCloudNuclearBodyBankCondition();
        condition.setCaseNo(bankChange.getCaseNo());
        condition.setNewBank(bankChange.getNewBank());
        condition.setNewBankAccount(bankChange.getNewBankAccount());
        condition.setNewCardholder(bankChange.getNewCardholder());
        condition.setOldBank(bankChange.getOldBank());
        condition.setOldBankAccount(bankChange.getOldBankAccount());
        condition.setOldCardholder(bankChange.getOldCardholder());
        return new IResponse().setData(bankChange);
    }


    @ApiOperation(value = "查询银行卡详情")
    @PostMapping("/findBankCardDetail")
    public IResponse findBankCardDetail(@RequestBody BankCardDetilCondition bankCardChange) {
        ManageBankCardChange contract = new ManageBankCardChange();
        if (bankCardChange.getCaseNo()!=null) {
            LambdaQueryWrapper<ManageBankCardChange> wrapper = Wrappers.<ManageBankCardChange>lambdaQuery()
                    .eq(ManageBankCardChange::getCaseNo, bankCardChange.getCaseNo());
            contract = bankCardChangeService.getOne(wrapper);
            ManageBankCardChange bankCardData = bankCardChangeService.getOne(Wrappers.<ManageBankCardChange>lambdaQuery()
                    .eq(ManageBankCardChange::getCaseNo,bankCardChange.getCaseNo()));
            BeanUtils.copyProperties(bankCardChange,contract);
        }
        //查询到已完成状态的记录，返回空值
        if (contract == null || contract.getCaseNo() == null) {
            ManageBankCardChange bankCard = new ManageBankCardChange();
            return new IResponse().setData(bankCard);
        }
        return new IResponse().setData(contract);
    }

    @ApiOperation(value = "删除银行卡变更信息")
    @PostMapping("/delBankCardChange")
    public IResponse delBankCardChange(@RequestBody ManageBankCardChange bankCardChange) {
        bankCardChangeService.remove(Wrappers.<ManageBankCardChange>lambdaQuery()
                .eq(ManageBankCardChange::getCaseNo, bankCardChange.getCaseNo()));
        return new IResponse().success("删除成功");
    }


    @PostMapping("/submitBankManage")
    @ApiOperation(value = "提交身份变更信息")
    @Transactional(rollbackFor = Exception.class)
    public IResponse submitCancelRecord(@RequestBody BankCardManageVO bankVO) {
        bankCardChangeService.submitBankCardRecord(bankVO);
        return new IResponse<Boolean>().setData(true).setMsg("流程提交成功！");
    }

    @PostMapping("/saveProposalApplicationInfo")
    @ApiOperation(value = "流程审批操作")
    @Transactional(rollbackFor = Exception.class)
    public IResponse saveProposalApplicationInfo(@RequestBody BankApprovalVo bankVOs) {
        bankCardChangeService.saveProposalApplicationInfo(bankVOs);
        return new IResponse<Boolean>().setData(true).setMsg("流程审批成功！");
    }


    @PostMapping(value = "/bankCardChangeStatus")
    @ApiOperation(value = "还款银行卡变更审批状态查询")
    public IResponse<List<ManageBankCardChange>> bankCardChangeStatus(@RequestParam("contractNos") String contractNos) {

        List<String> contractNoList = Arrays.asList(contractNos.split(","));
        List<ManageBankCardChange> bankCardChangeList = bankCardChangeService.list(Wrappers.<ManageBankCardChange>query().lambda()
                .in(ManageBankCardChange::getContractNo, contractNoList)
        );
        if (EmptyUtils.isEmpty(bankCardChangeList)) {
            bankCardChangeList = new ArrayList<>();

        }
        return IResponse.success(bankCardChangeList);
    }

    @PostMapping(value = "/verify")
    @ApiOperation(value = "短信验证码")
    public IResponse<ApplySigningInfoDTO> doVerify(@RequestBody ApplySigningInfoDTO signingInfoDTO) {

        String chlCd = null;
        Map<String, List<DicDataDto>> dicMap = DicHelper.getDicMaps("mappingBank");
        List<DicDataDto> dicList = dicMap.get("mappingBank");
        for (DicDataDto dto : dicList) {
            if (dto.getValue().equals(signingInfoDTO.getNewBank())) {
                chlCd = dto.getTitle();
            }
        }


        Assert.isTrue(!org.springframework.util.ObjectUtils.isEmpty(chlCd), "无此银行代码的通道[{}]", signingInfoDTO.getNewBank());
        signingInfoDTO.setChlCd(chlCd);
        SigningCustInfoDTO signingCustInfoDTO = new SigningCustInfoDTO();
        signingCustInfoDTO.setChlCd(chlCd);
        signingCustInfoDTO.setTel(signingInfoDTO.getTel());
        signingCustInfoDTO.setCardNo(signingInfoDTO.getCardNo());
        signingCustInfoDTO.setPayAcctNm(signingInfoDTO.getNewCardholder());
        signingCustInfoDTO.setPayAcctNo(signingInfoDTO.getNewBankAccount());
        signingInfoDTO.setBody(signingCustInfoDTO);
        signingInfoDTO.setOpenid(contractFeginConfig.getOpenid());
        signingInfoDTO.setAppid(contractFeginConfig.getAppid());
        Date dt = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        String data = sdf.format(dt);
        Long reqtime = Long.parseLong(data);
        String uuid = generateShortUUID();
        signingInfoDTO.setMsgid(reqtime.toString() + uuid);
        signingInfoDTO.setReqtime(reqtime);
        JSONObject jsonObject = contractSigningFeign.doVerify(signingInfoDTO);
        log.info("contractSigningFeign.doVerify(signingInfoDTO)====>" + contractSigningFeign.doVerify(signingInfoDTO));
        ApplySigningInfoDTO applySigningInfoDTO = jsonObject.toJavaObject(jsonObject, ApplySigningInfoDTO.class);
        ManageBankCardChange manageBankCardChange = new ManageBankCardChange();
        manageBankCardChange.setId(signingInfoDTO.getId());
        manageBankCardChange.setSignSite(signingInfoDTO.getSignSite());
        bankCardChangeService.updateById(manageBankCardChange);
        if (applySigningInfoDTO.getResultcode().equals("000000")) {
            return new IResponse<ApplySigningInfoDTO>().setData(applySigningInfoDTO);
        } else {
            return new IResponse<ApplySigningInfoDTO>().setMsg("短信发送失败");
        }

    }

    @PostMapping(value = "/sign")
    @ApiOperation(value = "银行签约")
    public IResponse<ApplySigningInfoDTO> doSign(@RequestBody ApplySigningInfoDTO signingInfoDTO) {

        String chlCd = null;
        Map<String, List<DicDataDto>> dicMap = DicHelper.getDicMaps("mappingBank");
        List<DicDataDto> dicList = dicMap.get("mappingBank");
        for (DicDataDto dto : dicList) {
            if (dto.getValue().equals(signingInfoDTO.getNewBank())) {
                chlCd = dto.getTitle();
            }
        }
        Assert.isTrue(!org.springframework.util.ObjectUtils.isEmpty(chlCd), "无此银行代码的通道[{}]", signingInfoDTO.getNewBank());
        signingInfoDTO.setChlCd(chlCd);
        SigningCustInfoDTO signingCustInfoDTO = new SigningCustInfoDTO();
        signingCustInfoDTO.setChlCd(chlCd);
        signingCustInfoDTO.setTelNo(signingInfoDTO.getTel());
        signingCustInfoDTO.setCardNo(signingInfoDTO.getCardNo());
        signingCustInfoDTO.setPayAcctName(signingInfoDTO.getNewCardholder());
        signingCustInfoDTO.setPayAcctNo(signingInfoDTO.getNewBankAccount());
        signingCustInfoDTO.setVc(signingInfoDTO.getVc());
        signingCustInfoDTO.setOperType("0");
        signingInfoDTO.setBody(signingCustInfoDTO);
        signingInfoDTO.setOpenid(contractFeginConfig.getOpenid());
        signingInfoDTO.setAppid(contractFeginConfig.getAppid());
        Date dt = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        String data = sdf.format(dt);
        Long reqtime = Long.parseLong(data);
        String uuid = generateShortUUID();
        signingInfoDTO.setMsgid(uuid + reqtime.toString());
        signingInfoDTO.setReqtime(reqtime);
        JSONObject jsonObject = contractSigningFeign.doSign(signingInfoDTO);
        ApplySigningInfoDTO applySigningInfoDTO = jsonObject.toJavaObject(jsonObject, ApplySigningInfoDTO.class);

        if (applySigningInfoDTO.getResultcode().equals("000000")) {
            ManageBankCardChange manageBankCardChange = new ManageBankCardChange();
            manageBankCardChange.setId(signingInfoDTO.getId());
            manageBankCardChange.setSignResult(applySigningInfoDTO.getResultcode());
            manageBankCardChange.setSignStutas("0");
            bankCardChangeService.updateById(manageBankCardChange);
            return new IResponse<ApplySigningInfoDTO>().setData(applySigningInfoDTO);
        } else {
            return new IResponse<ApplySigningInfoDTO>().setMsg("签约失败");
        }

    }

    @PostMapping(value = "/findBankCardInfo")
    @ApiOperation(value = "根据合同号查询银行变更信息")
    public IResponse findBankCardInfo(@RequestBody String[] caseNo) throws ParseException {
        List<ManageBankCardChange> bankCardChanges = bankCardChangeService.list(Wrappers.<ManageBankCardChange>lambdaQuery()
                .in(ManageBankCardChange::getCaseNo, caseNo));
        List<BankCardManageVO> bankcardList = new ArrayList<>();
        //合同关闭日期+3个月
        for (ManageBankCardChange bankCardChange : bankCardChanges) {
            if (bankCardChange.getProcessStatus().equals(bankCardChanges.get(0).getProcessStatus())) {
                if (bankCardChange.getCloseDate() != null) {
                    BankCardManageVO vo = new BankCardManageVO();
                    Calendar endDate = Calendar.getInstance();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    String timeFormat = sdf.format(bankCardChange.getCloseDate());
                    Date endDatetime = sdf.parse(timeFormat);
                    endDate.setTime(endDatetime);
                    endDate.add(Calendar.MONTH, 3);
                    String defaultEndDate = sdf.format(endDate.getTime());
//                    bankCardChange.setEndDate(sdf.parse(defaultEndDate));
                    //同行变更才显示原账号
                    if (!(bankCardChange.getOldBank()).equals(bankCardChange.getNewBank())) {
                        bankCardChange.setOldBankAccount(null);
                        bankCardChange.setOldBank(null);
                        bankCardChange.setOldBranchBank(null);
                        bankCardChange.setOldCardholder(null);
                    }
                    BeanUtil.copyProperties(bankCardChange,vo);
                    vo.setCloseTime(DatePattern.CHINESE_DATE_FORMAT.format(sdf.parse(defaultEndDate)));
                    bankcardList.add(vo);
                }
            }

        }

        return new IResponse().setData(bankcardList);
    }

    @PostMapping("/getOCRBankInfo")
    @ApiOperation(value = "OCR识别填充数据")
    public IResponse getOCRInfo(@RequestBody BankCardDetilCondition vo) {
        //非草稿状态，不进行数据识别
        BankCardOCRVO bankCardChange = new BankCardOCRVO();
        ManageBankCardChange bankCardData = bankCardChangeService.getOne(Wrappers.<ManageBankCardChange>lambdaQuery()
                .eq(ManageBankCardChange::getCaseNo,vo.getCaseNo()));
        if(bankCardData.getProcessStatus() != ProcessStatusEnum.draft){
            return new IResponse().setData(null);
        }
        List<ComAttachementFile> idCardFront = comAttachementFileService.list(Wrappers.<ComAttachementFile>lambdaQuery()
                .eq(ComAttachementFile::getBusiNo, vo.getCaseNo())
                .eq(ComAttachementFile::getAttachmentCode, BankTemplateIdEnum.BankChangeIdCardFrontCode.getDesc())
                .orderByDesc(ComAttachementFile::getCreateTime));
        List<ComAttachementFile> bankCardFront = comAttachementFileService.list(Wrappers.<ComAttachementFile>lambdaQuery()
                .eq(ComAttachementFile::getBusiNo, vo.getCaseNo())
                .eq(ComAttachementFile::getAttachmentCode, BankTemplateIdEnum.BankChangeBankCardFrontCode.getDesc())
                .orderByDesc(ComAttachementFile::getCreateTime));
        if (idCardFront.size() != 0) {//身份证正面
            OcrDiscernCondition idCardFrontCondition = new OcrDiscernCondition();
            idCardFrontCondition.setCaseCode(vo.getCaseNo()); //业务编号
            idCardFrontCondition.setInletEnd("PC");//进件端
            idCardFrontCondition.setSysCode("ICOS");//系统标识
            idCardFrontCondition.setFileCode("idCardFront");//文件类型
            idCardFrontCondition.setFileMd5(idCardFront.get(0).getFileId());
            IdCardFrontOcrDiscernVo idCardFrontOcrDiscern = contractOCRInterService.getIdCardFrontOcrDiscern(idCardFrontCondition);
            if(idCardFrontOcrDiscern !=null) {
                bankCardChange.setCustInfoMd5(idCardFrontCondition.getFileMd5());
                bankCardChange.setNewCardholder(StringUtils.isNotEmpty(idCardFrontOcrDiscern.getName()) ? idCardFrontOcrDiscern.getName() : null);
                bankCardChange.setCertNo(idCardFrontOcrDiscern.getNumber());
            }
        }
        if (bankCardFront.size() != 0) {//银行卡正面
            OcrDiscernCondition bankCardBackCondition = new OcrDiscernCondition();
            bankCardBackCondition.setCaseCode(vo.getCaseNo()); //业务编号
            bankCardBackCondition.setInletEnd("PC");//进件端
            bankCardBackCondition.setSysCode("ICOS");//系统标识
            bankCardBackCondition.setFileCode("bankCard");//文件类型
            bankCardBackCondition.setFileMd5(bankCardFront.get(0).getFileId());
            BankCardOcrDiscernVo bankCardBackOcrDiscern = contractOCRInterService.getBankCardOcrDiscern(bankCardBackCondition);
            if (bankCardBackOcrDiscern != null &&
                    bankCardBackOcrDiscern.getBankCardNumber() != null &&
                    bankCardBackOcrDiscern.getBankCardNumber() != "") {
                bankCardChange.setBankCardMd5(bankCardBackCondition.getFileMd5());
                bankCardChange.setNewBankAccount(bankCardBackOcrDiscern.getBankCardNumber());
            }else{
                return new IResponse().setData(bankCardBackCondition);
            }
        }
        if ((idCardFront.size() == 0
                && bankCardFront.size() == 0)
                || vo.getCaseNo()==null){
            return new IResponse().setData(null);
        }
        return new IResponse().setData(bankCardChange);
    }


    public static String generateShortUUID() {
        StringBuffer shortBuffer = new StringBuffer();
        String uuid = UUID.randomUUID().toString().replace("-", "");
        for (int i = 0; i < 18; i++) {
            String str = uuid.substring(i * 1, i * 1 + 1);
            int x = Integer.parseInt(str, 16);
            shortBuffer.append(chars[x % 0x3E]);
        }
        return shortBuffer.toString();
    }

    public static String[] chars = new String[]{"a", "b", "c", "d", "e", "f",
            "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
            "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
            "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
            "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
            "W", "X", "Y", "Z"};

    @PostMapping("/getBankCardInfo")
    @ApiOperation(value = "根据业务编号查询变更数据")
    public IResponse getBankCardInfo(@RequestBody SmallprogramDto vo) {
        BankCardManageVO bankCardManageVO = new BankCardManageVO();
        ManageBankCardChange bankCardData= bankCardChangeService.getOne(Wrappers.<ManageBankCardChange>lambdaQuery()
                .eq(ManageBankCardChange::getCaseNo, vo.getCaseNo()));
        bankCardData.setNewBank(TranslateBankCodeUntil.translateBankCode(bankCardData.getNewBank()));
        bankCardData.setOldBank( TranslateBankCodeUntil.translateBankCode(bankCardData.getOldBank()));
        TsysAddressParam oldProvince = tsysAddressParamService.getOne(Wrappers.<TsysAddressParam>lambdaQuery()
                .eq(TsysAddressParam::getValue, bankCardData.getOldProvince()));
        TsysAddressParam oldCity = tsysAddressParamService.getOne(Wrappers.<TsysAddressParam>lambdaQuery()
                .eq(TsysAddressParam::getValue, bankCardData.getOldCity()));
        TsysAddressParam province = tsysAddressParamService.getOne(Wrappers.<TsysAddressParam>lambdaQuery()
                .eq(TsysAddressParam::getValue, bankCardData.getProvince()));
        TsysAddressParam city = tsysAddressParamService.getOne(Wrappers.<TsysAddressParam>lambdaQuery()
                .eq(TsysAddressParam::getValue, bankCardData.getCity()));
        bankCardData.setOldProvince(oldProvince.getLabel());
        bankCardData.setOldCity(oldCity.getLabel());
        bankCardData.setProvince(province.getLabel());
        bankCardData.setCity(city.getLabel());
        BeanUtils.copyProperties(bankCardData,bankCardManageVO);
        List<ComAttachementFile> comAttachementFile = comAttachementFileService.list(Wrappers.<ComAttachementFile>lambdaQuery()
                .eq(ComAttachementFile::getBusiNo,vo.getCaseNo())
                .orderByDesc(ComAttachementFile::getCreateTime));
        List<ComPrintFormSealMapping> comPrintFormSealMapping = comPrintFormSealMappingService.list(Wrappers.<ComPrintFormSealMapping>lambdaQuery()
                .eq(ComPrintFormSealMapping::getTemplateId,comAttachementFile.get(0).getAttachmentCode()));
        if (comPrintFormSealMapping.get(0).getKeyword() == null) {
            bankCardManageVO.setKeyWord(comPrintFormSealMapping.get(0).getKeyword());
        }
        bankCardManageVO.setKeyWord("签字");
        log.info("获取的数据为",bankCardManageVO);
        return new IResponse().setData(bankCardManageVO);
    }
    @PostMapping("/getBankCardPermit")
    @ApiOperation(value = "根据业务编号查询打印的模板信息")
    public IResponse getBankCardPermit(@RequestBody SmallprogramDto vo) {
        SmallprogarmTemplateCondition condition = new SmallprogarmTemplateCondition();
        List<ComAttachementFile> comAttachementFile = comAttachementFileService.list(Wrappers.<ComAttachementFile>lambdaQuery()
                .eq(ComAttachementFile::getBusiNo,vo.getCaseNo())
                .eq(ComAttachementFile::getAttachmentCode,"mergeFile")
                .orderByDesc(ComAttachementFile::getCreateTime));
        BeanUtils.copyProperties(comAttachementFile.get(0),condition);
        condition.setBusiNo(vo.getCaseNo());
        return new IResponse().setData(condition);
    }

}


